var app = angular.module('myApp',[]);
app.controller('consoleCtrl', function ($scope) {

    $scope.ff = [
        // {
        //     name: '简介',
        //     state: 'Console.Portal',
        //     clazz: 'fu fu-overview'
        // },
        {
            name: '概览',
            state: 'Console.Overview',
            clazz: 'fu fu-overview'
        },
        {
            name: '工具管理',
            state: 'Console.Tools',
            clazz: 'fu fu-overview ',

        },
        {
            name: '批量管理',
            state: 'Console.Batchs',
            clazz: 'fu fu-overview ',

        },
        {
            name: '实例列表',
            state:'Console.Caselist',
            clazz: 'fu fu-overview',
            children: [{
                name: '实例信息1',
                state: 'Console.Caseinfo',
            }, {
                name: '实用功能2',
                state: 'Console.Casefunc'
            },{
                name: '实用功能3',
                state: 'Console.Casefunc'
            }]
        },
        {
            name: 'Sentinel管理',
            state: '',
            clazz: 'fu fu-overview'
        },
        {
            name: '系统管理',
            state: '',
            clazz: 'fu fu-overview'
        }
    ]
});



app.directive('yttMenu', function () {

    let ctrl = function ($scope) {

        $scope.children = [];
        this.addMenu = menu => {
            $scope.children.push(menu);
        }
    };
    return {
        restrict:'AE',
        replace:true,
        transclude:true,
        scope:true,
        controller:ctrl,
        templateUrl:'menu.html'

    }
});
app.directive('yttMenuItem', function () {

    let ctrl = function ($scope) {
        $scope.children = [];
        this.addMenu = menu => {
            $scope.children.push(menu);
            console.log($scope.children);
        };
    };
    let link = function (scope,element,attr,yttMenu) {
        console.log('pp',yttMenu);
        let a = element.find('> a');
        a.append(element.find('>ul>t'));
        a.append();
    };
    return {
        restrict:'AE',
        replace:true,
        transclude:true,
        require:'^yttMenu',
        scope:{},
        controller:ctrl,
        compile: (element, attrs, transcludeFn) => {
            let a = element.find('a');
            return {
                post: link
            }
        },
        templateUrl:'menuItem.html'
    }
});
app.directive('yttMenuItem2', function () {

    let ctrl = function ($scope) {

        $scope.children = [];
        this.addMenu = menu => {
            $scope.children.push(menu);

        };
    };
    let link = function (scope,element,attr,yttMenuItem) {
        yttMenuItem.addMenu(scope);
        let a = element.find('> a');
        a.append(element.find('>ul>t'));
        a.append();
    };
    return {
        restrict:'AE',
        replace:true,
        transclude:true,
        require:'^yttMenuItem',
        scope:{},
        controller:ctrl,
        compile: function () {
            return {
                post: link
            }
        },
        templateUrl:'menuItem2.html'

    }
});